from selenium import webdriver
from pprint import pprint

driver = webdriver.Chrome(executable_path=r"C:\00pcao\01soft\chromedriver.exe")
driver.get('https://www.baidu.com')
element = driver.find_element_by_xpath('//input[@id="kw"]')
attrs = driver.execute_script('var items = {}; for (index = 0; index < arguments[0].attributes.length; ++index) { items[arguments[0].attributes[index].name] = arguments[0].attributes[index].value }; return items;', element)
pprint(attrs)

